Merged
Conversation
Collaborator
Author
|
While I was fixing #317 I found this macro and concluded it was both irredeemable and unnecessary. Using |
a3a1ef6 to
709e14b
Compare
It's wildly unsound, as far as I can tell. - The use of `UnsafeCell`/`unsafe impl Send`/`unsafe impl Sync` is very dodgy. - The use of `MaybeUninit<[T; N]>` is completely wrong. It should be `[<MaybeUninit<T>; N>]`, which allows for partial initialization. - The examples don't use `write`/`assume_init` with `MaybeUninit`, which is UB. The alternative is to use `#[address_space(shared) static mut [MaybeUninit<T>; N]` directly instead. That avoids all the unsoundness, and is more ergonomic because you don't have to work with a raw pointer, and is clearer because details aren't hidden within the macro. I moved (with some modifications) the comments on `shared_array` to the `address_space` proc macro because there were some useful details in there.
This was non-obvious to me, and took a minute to work out.
709e14b to
54dcb94
Compare
LegNeato
approved these changes
Nov 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It's wildly unsound, as far as I can tell.
UnsafeCell/unsafe impl Send/unsafe impl Syncis very dodgy.MaybeUninit<[T; N]>is completely wrong. It should be[<MaybeUninit<T>; N>], which allows for partial initialization.write/assume_initwithMaybeUninit, which is UB.The alternative is to use
#[address_space(shared) static mut [MaybeUninit<T>; N]directly instead. That avoids all the unsoundness, and is more ergonomic because you don't have to work with a raw pointer, and is clearer because details aren't hidden within the macro.I moved (with some modifications) the comments on
shared_arrayto theaddress_spaceproc macro because there were some useful details in there.